/* 
 * File:   File.h
 * Author: Maxwell
 *
 * Created on February 28, 2011, 8:15 PM
 */

#ifndef FILE_H
#define	FILE_H

#include "FreeList.h"
#include "Directory.h"
#include "Disk.h"
#include "FileException.h"
#include "BlockGroup.h"
#include "BlockLinkedList.h"
#include "FCB.h"
#include <stdio.h>
#include <iostream>
#include <string>

class File {

    public:
        File(char* name, char mode);
        ~File();
        bool Close();
        static bool Delete(char* name);
        static bool Exists(char* name);
        void Open(char mode);
        static void List();
        void ByteCopy(char* dest, char* source, int length);
        int Write(char* buffer, int size);
        int Read(char* buffer, int size);
        void SwitchMode(char m);
        static void Test();
        static void Initialize(FreeList *f, Directory *d);

    private:
        int Read(int lseek, char* buffer, int size);

        static FreeList *m_freelist;
        static Directory *m_directory;
        static Disk *m_disk;

        char m_mode;
        bool m_fileOpen;
        int m_readCursor;
        int m_numBytes;
        FCB *m_fcb;
        BlockGroup *m_blockgroup;


};

    

#endif	/* FILE_H */

